{include header}
<link href="{#WWW}/public/css/simditor.css" type="text/css" rel="stylesheet">
{hook t_post_index_1}
<label>标题 <span></span></label>
<select id="forum" type="text" class="text " style="width:150px;margin-bottom:10px">
<option value="-1">请选择一个分类</option>
{foreach $forum as $v}
<option value="{$v['id']}">{$v['name']}</option>
{/foreach}
</select>
<input type="text" id="title" class="text " placeholder="请填写标题">
{hook t_post_index_2}
<label>发表内容 <span></span></label>
<textarea id="editor" autofocus></textarea>
{hook t_post_index_3}
<button type="button" class="btn btn-primary" id="post1"><i class="am-icon-check"></i> 发 表</button>
<script src="{#WWW}/public/js/edit.min.js"></script>

<script>
$(function(){
    $("#post1").click(function(){
        var forum = $("#forum").val();


        $.ajax({
         url: '{#WWW}/post.html',
         type:"POST",
         cache: false,
         data:{
             title:$("#title").val(),
             content:editor.textarea.val(),
             forum:forum,
             {hook t_post_index_4}
         },
         dataType: 'json'
     }).then(function(e) {
         {hook t_post_index_5}
         alert(e.info);
         if(e.error)
            window.location.href="{#WWW}/thread/"+e.id+".html";
       }, function() {
           {hook t_post_index_6}
         alert('请尝试重新提交');
       });
    })
})
</script>
{include footer}
